/**
 * 全局指令
 */
import { fmtUrl ,btnPermissionControl} from './filters'

const imageMap = {
  'common': '',
  'pdf': '/images/default/pdf.jpg',
  'video': '/images/default/video.png',
  'avatar': '/images/team/default-avatar.png'
}

export default {
  // 背景图
  bg (el, binding) {
    var value = binding.value
    var arg = binding.arg || 'commom'

    el.style.backgroundImage = `url("${ fmtUrl(value || imageMap[arg]) }")`
  },
  bgSmall (el, binding) {
    var value = binding.value
    var arg = binding.arg || 'commom'

    el.style.backgroundImage = `url("${ fmtUrl(value || imageMap[arg]) }?small=1")`
  },
  permit(el,binding){
    if(binding.value){
      const result = btnPermissionControl(binding.value);
      if(!result){
        el.style.display="none";
      }
    }
  }
}

